﻿#include "SpriteFont.h"


Sprite::SpriteFont::SpriteFont()
{
	m_fontDesc.Height          = 24;
	m_fontDesc.Width           = 0;
	m_fontDesc.Weight          = 0;
	m_fontDesc.MipLevels       = 1;
	m_fontDesc.Italic          = false;
	m_fontDesc.CharSet         = DEFAULT_CHARSET;
	m_fontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
	m_fontDesc.Quality         = DEFAULT_QUALITY;
	m_fontDesc.PitchAndFamily  = DEFAULT_PITCH | FF_DONTCARE;
	wcscpy(m_fontDesc.FaceName, L"Times New Roman");
	
	if (dynamic_cast<SpriteD3D10*>(const_cast<SpriteD3D*>(g_pCD3d)))
	{
		m_pCD3d = g_pCD3d;
		D3DX10CreateFontIndirect(m_pCD3d->getDevice10(), &m_fontDesc, &m_Font);
	}
		this->m_Color = SpriteColor(0,0,0,1);
		RECT r = {5,5,0,0};
		this->m_rect = r;
		this->m_nFormat = DT_NOCLIP;
}

Sprite::SpriteFont::~SpriteFont( void )
{
	ReleaseCOM(this->m_Font);
}

int Sprite::SpriteFont::draw( std::wstring tex )
{
	return m_Font->DrawText(0, tex.c_str(), -1, &m_rect, m_nFormat, m_Color);
}
